package com.gateon.hw.api.mobile.controller;

import com.gateon.hw.base.vo.Result;
import com.gateon.hw.client.system.client.UserClient;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: hw
 * @description: qiuheyi
 * @author: qhy
 * @create: 2020-09-01 10:36
 **/
@Api(value = "测试用户")
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserClient userClient;

    /**
     * 测试服务熔断
     * @param id
     * @return
     */
    @ApiOperation(value = "删除")
    @GetMapping("/delete/{id}")
    @HystrixCommand(fallbackMethod = "getHystrix")
    public Result get(@PathVariable("id") Long id) {
        throw new RuntimeException();
    }

    public Result getHystrix(@PathVariable("id") Long id) {
        return Result.withData("服务熔断");
    }
}
